package gunfire.cards;

import basemod.abstracts.CustomCard;
import com.megacrit.cardcrawl.actions.AbstractGameAction;
import com.megacrit.cardcrawl.actions.common.DamageAction;
import com.megacrit.cardcrawl.actions.common.HealAction;
import com.megacrit.cardcrawl.actions.common.LoseHPAction;
import com.megacrit.cardcrawl.actions.utility.WaitAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.localization.CardStrings;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import gunfire.GunfireMod;

import static gunfire.GunfireMod.makeCardPath;

public class StoneSkin1 extends CustomCard {

    public static final String ID = GunfireMod.makeID(StoneSkin1.class.getSimpleName());
    private static final CardStrings cardStrings = CardCrawlGame.languagePack.getCardStrings(ID);
    public static final String NAME = cardStrings.NAME;
    public static final String DESCRIPTION = cardStrings.DESCRIPTION;
    public static final String IMG = makeCardPath("StoneSkin.png");
    private static final CardRarity RARITY = CardRarity.SPECIAL;
    private static final CardType TYPE = CardType.SKILL;
    private static final CardTarget TARGET = CardTarget.SELF;
    public static final CardColor COLOR = CardColor.COLORLESS;
    private static final int COST = -2;
    private AbstractCard originalCard;

    public StoneSkin1() {
        super(ID, NAME, IMG, COST, DESCRIPTION, TYPE, COLOR, RARITY, TARGET);
        this.baseMagicNumber = this.magicNumber = 12;
    }

    public StoneSkin1(AbstractCard originalCard){
        this();
        this.originalCard = originalCard;
    }

    @Override
    public void upgrade() {
        if (!this.upgraded) {
            this.upgradeName();
            this.upgradeMagicNumber(5);
        }
    }

    @Override
    public void use(AbstractPlayer p, AbstractMonster m) {
        this.onChoseThisOption();
    }

    @Override
    public void onChoseThisOption() {
        AbstractPlayer p = AbstractDungeon.player;
        AbstractCard oc = this.originalCard;
        this.addToBot(new LoseHPAction(p, p, Math.min(5, p.currentHealth - 1)));
        this.addToBot(new WaitAction(0.75F));
        this.addToBot(new HealAction(p, p, this.magicNumber));
        this.addToBot(new AbstractGameAction() {
            @Override
            public void update() {
                p.discardPile.moveToExhaustPile(oc);
                this.isDone = true;
            }
        });
    }

    @Override
    public AbstractCard makeCopy() {
        return new StoneSkin1();
    }
}
